package dao;

import domain.User;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import utils.JDBCutils;

public class Userdao {
    private JdbcTemplate template=new JdbcTemplate(JDBCutils.getDataSource());
    public User login(User user){

        try {
            String sql="select * from user where username= ? and password=? ";
            User u = template.queryForObject(sql, new BeanPropertyRowMapper<>(User.class), user.getUsername(), user.getPassword());
            return u;
        } catch (DataAccessException e) {
            e.printStackTrace();
        }return null;
    }
}
